package com.malamute.system.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.malamute.core.common.Page;
import com.malamute.system.dao.UserDao;
import com.malamute.system.entity.User;
import com.malamute.system.service.UserService;

/**
 * @Title:UserServiceImpl.java
 * @Package com.cafe.business.user
 * @Description 员工业务接口实现
 * @author AceGuan gjybst@163.com
 * @date 2012-1-28 下午02:30:57
 * @version v1.0
 */
@Service
public class UserServiceImpl implements UserService {
	@Autowired(required = false)
	private UserDao userDao;

	/**
	 * 设置userDao
	 * 
	 * @param userDao
	 */
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param user
	 * 
	 * @see com.cafe.business.user.UserService#registerUser(com.cafe.model.User)
	 */
	@Override
	public void saveUser(User user) {
		userDao.save(user);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param id
	 * 
	 * @return
	 * 
	 * @see com.cafe.business.user.UserService#getUserById(long)
	 */
	@Override
	public User getUserById(int id) {
		return (User) userDao.get(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param user
	 * 
	 * @see com.cafe.business.user.UserService#updateUser(com.cafe.model.User)
	 */
	@Override
	public void updateUser(User user) {
		userDao.update(user);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param id
	 * 
	 * @see com.cafe.business.user.UserService#deleteUserById(long)
	 */
	@Override
	public void deleteUserById(int id) {
		userDao.deleteByKey(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.cafe.service.UserService#listByPage(org.hibernate.criterion.
	 * DetachedCriteria, com.malamute.core.common.Page)
	 */
	@Override
	public void listUsersByPage(DetachedCriteria criteria, Page page) {
		userDao.listByPage(criteria, page);

	}

	@Override
	public List findUsersByUsername(DetachedCriteria criteria) {
		return userDao.findByCriteria(criteria);
	}

}
